package com.uqpsoftware.uqplist;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.widget.Toast;

public class Util {

	// debug mode
	public static boolean DEBUG = false;

	public static List<TabList> sort(List<TabList> originalList) {
		List<TabList> sortedList = new ArrayList<TabList>();
		int iterations = originalList.size();
		for (int i = 0; i < iterations; ++i) {
			int maximum = Integer.MIN_VALUE;
			TabList tabWithMaximumID = null;
			for (TabList tl : originalList) {
				if (tl.getID() >= maximum) {
					maximum = tl.getID();
					tabWithMaximumID = tl;
				}
			}
			sortedList.add(tabWithMaximumID);
			originalList.remove(tabWithMaximumID);
		}
		return sortedList;
	}

	public static List<TabList> reverse(List<TabList> originalList) {
		List<TabList> reversedList = new ArrayList<TabList>();
		for (int i = originalList.size() - 1; i >= 0; --i) {
			reversedList.add(originalList.get(i));
		}
		return reversedList;
	}

	public static void debugToast(Context mContext, String message) {
		if (DEBUG) {
			Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
		}
	}

}
